/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NonNull;
import me.zhengjie.base.BaseEntity;
import me.zhengjie.utils.enums.AuditEnum;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
* @website https://docs.auauz.net
* @description /
* @author berry
* @date 2020-06-06
**/
@Entity
@Data
@Table(name="supplier_audit_history")
public class SupplierAuditHistory extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "ID")
    private Long id;

    @Column(name = "supplier_id",nullable = false)
    @NotNull
    @ApiModelProperty(value = "供应商ID")
    private Long supplierId;

    @Column(name = "supplier_name")
    @ApiModelProperty(value = "供应商名称")
    private String supplierName;

    @Column(name = "old_status", nullable = false)
    @NotNull
    @ApiModelProperty(value = "旧状态")
    @Convert(converter = AuditEnum.Converter.class)
    private AuditEnum oldStatus;

    @Column(name = "status", nullable = false)
    @NotNull
    @ApiModelProperty(value = "新状态")
    @Convert(converter = AuditEnum.Converter.class)
    private AuditEnum status;

    public static SupplierAuditHistory fromSupplier(Supplier source){
        SupplierAuditHistory supplierAuditHistory = new SupplierAuditHistory();
        supplierAuditHistory.setSupplierId(source.getId());
        supplierAuditHistory.setSupplierName(source.getName());
        supplierAuditHistory.setOldStatus(source.getStatus());
        return supplierAuditHistory;
    }
}